import socket
import os
from DesModule import *

file1 = open("秘密", "w+")
ciphertext = des_encrypt("hello~", "12345678")
file1.write(ciphertext)
file1.seek(0)  # 指针回到文件的开始位置，以便从头读取文件
cryptostring = file1.readline()  # 读取文件的第一行，此处应该是加密后的字符串
print(cryptostring)

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("172.16.208.90", 2025))
s.sendall(cryptostring.encode())  # 编码，发送
data = s.recv(1024)  # 接收，且最多接收1024字节
plaintext = des_descrypt(data.decode(), "12345678")
print("从服务器接收的数据为：", plaintext)

s.close()